function candy(cArr, pArr) {
    cArr.sort((a, b) => a - b)
    pArr.sort((a, b) => a - b)
    let index = 0;
    for (let i = 0; i < cArr.length; i++) {
        if (i < pArr.length && cArr[i] > pArr[index]) {
            index++
        }
    }
    return index

}